<?php

class Region extends CI_Model {

    private $regionBoundingBoxID;
    private $srs;
    private $region;
    private $minX;
    private $minY;
    private $maxX;
    private $maxY;

    function __construct() {
// Call the Model constructor
        parent::__construct();
    }

    public function getRegionBoundingBox() {
        return $this->regionBoundingBoxID;
    }

    public function setRegionBoundingBox($regionBoundingBox) {
        $this->regionBoundingBoxID = $regionBoundingBox;
    }

    public function getSrs() {
        return $this->srs;
    }

    public function setSrs($srs) {
        $this->srs = $srs;
    }

    public function getRegion() {
        return $this->region;
    }

    public function setRegion($region) {
        $this->region = $region;
    }

    public function getMinX() {
        return $this->minX;
    }

    public function setMinX($minX) {
        $this->minX = $minX;
    }

    public function getMinY() {
        return $this->minY;
    }

    public function setMinY($minY) {
        $this->minY = $minY;
    }

    public function getMaxX() {
        return $this->maxX;
    }

    public function setMaxX($maxX) {
        $this->maxX = $maxX;
    }

    public function getMaxY() {
        return $this->maxY;
    }

    public function setMaxY($maxY) {
        $this->maxY = $maxY;
    }

    public function getRegionBoundingBoxByName($name, $srs) {
        try {
            $this->db->select('r.descript as region, s.descript as srs ,rbb.minX, rbb.minY, rbb.maxX, rbb.maxY')
                    ->join('Srs s', 's.srsID = rbb.srsID')
                    ->join('Region r', 'r.regionID = rbb.regionID')
                    ->from('RegionBoundingBox rbb')
                    ->where('s.descript', $srs);

            if ($name) {
                $this->db->like('r.descript', $name);
            }

            return $this->db->get()->result();
        } catch (Exception $e) {
            return null;
        }
    }

}

?>
